<template>
  <div class="command__wrapper_container" v-show="visible">
    <el-container>
      <el-header :height="'45'">
        <svg-icon icon-class="table"></svg-icon>
        旅游报警
        <span class="el-icon-circle-close" @click="handleCloseDialog"></span>
      </el-header>
      <el-main>
        <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
          <el-form-item prop="content" label="报警内容" style="width: 67%">
            <el-input
              v-model="queryParams.content"
              style="width: 300px"
              placeholder="请输入查询内容"
              clearable
              size="small"
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
          <el-form-item style="width: 29%">
            <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
            <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
          </el-form-item>
        </el-form>
        <el-table v-loading="loading" :data="fenceAlarmList">
          <el-table-column label="主建id" align="center" prop="id" v-if="false"/>
          <el-table-column label="报警时间" align="center" prop="dateTime" width="180">
          </el-table-column>
          <el-table-column label="报警内容" align="center" prop="content" width="400"/>
          <el-table-column label="x" prop="x" v-if="false"/>
          <el-table-column label="y" prop="y" v-if="false"/>
          <el-table-column label="定位" align="center" class-name="small-padding fixed-width">
            <template slot-scope="scope">
              <el-button
                size="mini"
                type="text"
                icon="el-icon-location-information"
                @click="showTravelAlarmPoint(scope.row)"
              >定位
              </el-button>
            </template>
          </el-table-column>
          <el-table-column label="下派" align="center" class-name="small-padding fixed-width">
            <template slot-scope="scope">
              <el-button
                size="mini"
                type="text"
                icon="el-icon-location-information"
                @click="handleSave(scope.row)"
              >下派
              </el-button>
            </template>
          </el-table-column>
        </el-table>
        <pagination
          small
          layout="total,prev, pager, next"
          v-show="total>0"
          :total="total"
          :page.sync="queryParams.pageNum"
          :limit.sync="queryParams.pageSize"
          @pagination="getList"
        />
      </el-main>
    </el-container>
  </div>
</template>

<script>
  import { listForMap } from '@/api/basicInformation/travelAlarm'

  export default {
    name: 'fenceAlarm',
    components: {},
    props: {
      visible: {
        type: Boolean,
        default: false
      }
    },
    data() {
      return {
        // 遮罩层
        loading: true,
        // 显示搜索条件
        showSearch: true,
        // 总条数
        total: 0,
        // 巡护任务表格数据
        fenceAlarmList: [],
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          content: undefined,
          issue: 0,
          orderByColumn: 'dateTime',
          isAsc: 'desc'
        },
        stateTypeOptions: []
      }
    },
    created() {
      this.getList()
    },
    methods: {
      handleOpenDialog() {
      },
      handleCloseDialog() {
        this.$emit('close')
      },
      /** 查询巡护任务列表 */
      getList() {
        this.loading = false
        listForMap(this.queryParams).then(response => {
          this.fenceAlarmList = response.rows
          this.total = response.total
          this.showAlarmNum(this.total)
          this.loading = false
        })
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1
        this.getList()
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.resetForm('queryForm')
        this.handleQuery()
      },
      showAlarmNum(e) {
        this.$emit('showAlarmNum', e)
      },
      showTravelAlarmPoint(row) {
        this.$emit('showTravelAlarmPoint', row)
      },
      handleSave(e) {
        e.evtSource = '7'
        e.userSelectType = 1
        this.$emit('runHelp', e)
      }
    }
  }
</script>
<style scoped lang="scss">
  @import '../style/main';

  .el-form-item {
    margin-bottom: 10px;
  }
</style>
